<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */

$isSpecial = (int)$_data["isSpecial"];
if(strlen($_data["isSpecial"]) == 0)$isSpecial = 1;
$intSpecialNumType = (int)$_data["SpecialNumType"];
$isRealShow = (int)$_data["isRealShow"];
$intGID = (int)$_data["GambleID"];
$strPreBT = trim($_data["Bet_Type"]);

if($_data["isGetSuppleOdds"] == "Y"){
	$ch = curl_init ();
	$strBT = $strPreBT;
	if($intSpecialNumType == 2 || $intSpecialNumType == 4){
		$strBT = (preg_match("/^1,/", $strPreBT))?"2,3,16,28":"28";
	}
	curl_setopt($ch,CURLOPT_URL, "http://".$_KSysParam[SuppleIP]."/k_admin/Supplement/index.php?op=sendOdds&LottoID=".$intLottoID."&Bet_Type=".$strBT."&isSpecial=".$isSpecial."&GameType=".$_data["GameType"]);
	//curl_setopt ($ch, CURLOPT_VERBOSE, 1);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt ($ch, CURLOPT_HEADER, 0);
	curl_setopt ($ch, CURLOPT_HTTPHEADER, array(
			"Accept:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-shockwave-flash, */*",
			"User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)",
			"Host:".$_KSysParam[SuppleUrl],
			"Connection:Keep-Alive"));
	$strCont = curl_exec ($ch);
	curl_close ($ch);
	$strCont = preg_replace("/<[^\$]+>/", "", $strCont);

	if(preg_match("/arrGame/", $strCont)){
		eval($strCont);
	}else{
		$arrGame = array();
	}
}


$arrBType = split(",", $strPreBT);
if($strPreBT == "15"){
	$strSQL = "select a.Bet_Type as Bet_Type, a.Number as Number, SUM(b.MemStake) as tolStake, SUM(b.MemPayOff) as tolPayOff, SUM(b.MemStake*MemExchangeRate*DirectorRate) as tolRealStake, SUM(b.MemPayOff*MemExchangeRate*DirectorRate) as tolRealPayOff, COUNT(*) as tolWager, SUM(b.MemStake*MemExchangeRate*DirectorRate*DirectorCommission) as tolCommission  from `bet_ParlaysNumber` a, `bet_BetListTmp` b where a.BetListID = b.ID and b.GambleID = '".$intGID."' group by a.Bet_Type, a.Number";
	if(!$RS = PMA_mysql_query($strSQL, $$_Conn)){
		$GLOBALS["errormessage"] = "Find TodayGame Data Error!!";
		$GLOBALS["errorhidden"] = "Error: ".PMA_mysql_error($$_Conn)."\nSQL:".$strSQL."\nLine:".__LINE__."\nPage:".__FILE__;
		ErrMsgOutputHTML("Error", "", 1);
	}
	while($Rows = PMA_mysql_fetch_object($RS)){
		$arrBet[$Rows -> Bet_Type][$Rows -> Number] = $Rows;
	}
	
	$strSQL = "select * from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (12, 13, 14) order by Bet_Type";

}elseif(preg_match("/,1,|,28,/", ",".$strPreBT.",")){
	switch($intSpecialNumType){
		case 2:
			$strBT = (preg_match("/^1,/", $strPreBT))?"2, 3, 16, 28":"28";
			$strSQL = "select * from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (".$strBT.") order by Bet_Type";
			break;
		case 3:
		case 4:
			$strBT = (preg_match("/,/", $strPreBT))?"2, 3, 16":"0";
			$strSQL = "select GambleID, LottoID, Number, Bet_Type, OddsID, Odds, isStopBet, tolWager, tolStake, tolRealStake, tolPayOff, tolRealPayOff, tolJumpStake, tolCommission, tolSuppleWager, tolSuppleStake, tolSupplePayOff, tolSuppleCommission from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (".$strBT.") ";
			$strSQL .= "union select GambleID, LottoID, Number, Min(Bet_Type) as Bet_Type, Min(OddsID) as OddsID, Min(Odds) as Odds, Min(isStopBet) as isStopBet, Sum(tolWager) as tolWager, Sum(tolStake) as tolStake, Sum(tolRealStake) as tolRealStake, Sum(tolPayOff) as tolPayOff, Sum(tolRealPayOff) as tolRealPayOff, Sum(tolJumpStake) as tolJumpStake, Sum(tolCommission) as tolCommission, Sum(tolSuppleWager) as tolSuppleWager, Sum(tolSuppleStake) as tolSuppleStake, Sum(tolSupplePayOff) as tolSupplePayOff, Sum(tolSuppleCommission) as tolSuppleCommission from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (1, 28) group by GambleID, LottoID, Number";
			if($intSpecialNumType == 4)$strSQL = str_replace("Min(", "Max(", $strSQL);
			break;
		default:
			$strSQL = "select * from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (".$strPreBT.") order by Bet_Type";
			break;
	}

}else{
	$strSQL = "select * from `bet_TodayGame".$intLottoID."` where LottoID = ".$intLottoID." and GambleID = '".$intGID."' and Bet_Type in (".$strPreBT.") order by Bet_Type";
}
	//print $strSQL;
	//print_r($arrGame);

if(!$RS = PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find TodayGame Data Error!!";
	$GLOBALS["errorhidden"] = "Error: ".PMA_mysql_error($$_Conn)."\nSQL:".$strSQL."\nLine:".__LINE__."\nPage:".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	$GLOBALS["errormessage"] = "No TodayGame Data!!";
	//$GLOBALS["errorhidden"] = "Error: ".PMA_mysql_error($$_Conn)."\nLine:".__LINE__."\nPage:".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}
	
$sumStake = 0;
$sumPayOff = 0;
$sumCommission = 0;
$sumOUStake = 0;
$sumOUPayOff = 0;
$sumOUCommission = 0;
$sumOEStake = 0;
$sumOEPayOff = 0;
$sumOECommission = 0;
$sumSOEStake = 0;
$sumSOEPayOff = 0;
$sumSOECommission = 0;
$arrOE16Stake = array(0,0,0,0,0,0,0);
$arrOE16PayOff = array(0,0,0,0,0,0,0);
$arrOE16Commission = array(0,0,0,0,0,0,0);
$arrSOE16Stake = array(0,0,0,0,0,0,0);
$arrSOE16PayOff = array(0,0,0,0,0,0,0);
$arrSOE16Commission = array(0,0,0,0,0,0,0);
$arrOU16Stake = array(0,0,0,0,0,0,0);
$arrOU16PayOff = array(0,0,0,0,0,0,0);
$arrOU16Commission = array(0,0,0,0,0,0,0);
$arrColor16Stake = array(0,0,0,0,0,0,0);
$arrColor16PayOff = array(0,0,0,0,0,0,0);
$arrColor16Commission = array(0,0,0,0,0,0,0);
$arrSuppleOE16Stake = array(0,0,0,0,0,0,0);
$arrSuppleOE16PayOff = array(0,0,0,0,0,0,0);
$arrSuppleOE16Commission = array(0,0,0,0,0,0,0);
$arrSuppleOU16Stake = array(0,0,0,0,0,0,0);
$arrSuppleOU16PayOff = array(0,0,0,0,0,0,0);
$arrSuppleOU16Commission = array(0,0,0,0,0,0,0);
$arrSuppleColor16Stake = array(0,0,0,0,0,0,0);
$arrSuppleColor16PayOff = array(0,0,0,0,0,0,0);
$arrSuppleColor16Commission = array(0,0,0,0,0,0,0);
$arrSuppleSOE16Stake = array(0,0,0,0,0,0,0);
$arrSuppleSOE16PayOff = array(0,0,0,0,0,0,0);
$arrSuppleSOE16Commission = array(0,0,0,0,0,0,0);
$sumColorStake = 0;
$sumColorPayOff = 0;
$sumColorCommission = 0;
$sumAnimalsStake = 0;
$sumAnimalsPayOff = 0;
$sumAnimalsCommission = 0;
$arrHelfColorStake = array(0,0);
$arrHelfColorPayOff = array(0,0);
$arrHelfColorCommission = array(0,0);
$arrSuppleHelfColorStake = array(0,0);
$arrSuppleHelfColorPayOff = array(0,0);
$arrSuppleHelfColorCommission = array(0,0);
$arrSixAnimalsStake = array(0,0);
$arrSixAnimalsPayOff = array(0,0);
$arrSixAnimalsCommission = array(0,0);
$arrSuppleSixAnimalsStake = array(0,0);
$arrSuppleSixAnimalsPayOff = array(0,0);
$arrSuppleSixAnimalsCommission = array(0,0);
$arrSumStake = array();
$arrSumPayOff = array();
$arrSumCommission = array();
$arrSumSuppleStake = array();
$arrSumSupplePayOff = array();
$arrSumSuppleCommission = array();
while($Rows = PMA_mysql_fetch_object($RS)){
	if($isRealShow == 0){
		if($strPreBT == "15"){
			$tolStake = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolStake;
			$tolPayOff = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolPayOff;
			$tolWager = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolWager;
		}else{
			$tolStake = $Rows -> tolStake;
			$tolPayOff = $Rows -> tolPayOff;
			$tolWager = $Rows -> tolWager;
		}
		$tolCommission = 0;
	}else{
		if($strPreBT == "15"){
			$tolStake = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolRealStake;
			$tolPayOff = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolRealPayOff;
			$tolWager = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolWager;
			$tolCommission = $arrBet[$Rows -> Bet_Type][$Rows -> Number] -> tolCommission;
		}else{
			$tolStake = $Rows -> tolRealStake;
			$tolPayOff = $Rows -> tolRealPayOff;
			$tolWager = $Rows -> tolWager;
			$tolCommission = $Rows -> tolCommission;
		}
	}
	if(empty($tolStake))$tolStake = 0;
	if(empty($tolPayOff))$tolPayOff = 0;
	if(empty($tolCommission))$tolCommission = 0;
	if(empty($tolWager))$tolWager = 0;
	$tolSuppleWager = (empty($Rows -> tolSuppleWager))?0:$Rows -> tolSuppleWager;
	$tolSuppleStake = (empty($Rows -> tolSuppleStake))?0:$Rows -> tolSuppleStake;
	$tolSupplePayOff = (empty($Rows -> tolSupplePayOff))?0:$Rows -> tolSupplePayOff;
	$tolSuppleCommission = (empty($Rows -> tolSuppleCommission))?0:$Rows -> tolSuppleCommission;
	if($_data["isGetSuppleOdds"] == "Y"){
		$intOID = $arrGame[$Rows -> Bet_Type][$Rows -> Number][4];
		$flOdds = $arrGame[$Rows -> Bet_Type][$Rows -> Number][5];
	}else{
		$intApointNum = $_arrGLineNumToApointNum[$Rows -> LottoID][$Rows -> Bet_Type][$Rows -> Number];
		if($intApointNum == null)$intApointNum = 0;
		$flGLine = $_arrGambleType[$Rows -> Bet_Type][$intApointNum];

		$intOID = $Rows -> OddsID;
		$flOdds = $Rows -> Odds + $flGLine;
	}
	$intBT = ($Rows -> Bet_Type == 28)?1:$Rows -> Bet_Type;
	$strCon .= "parent.Game".$intBT."[".$Rows -> Number."]=new Array('".$Rows -> LottoID."','".$Rows -> GambleID."','".$Rows -> Bet_Type."','".$Rows -> Number."','".$intOID."','".$flOdds."','".$Rows -> isStopBet."','".$tolWager."','".$tolStake."','".$tolPayOff."','".$tolCommission."','".$tolSuppleWager."','".$tolSuppleStake."','".$tolSupplePayOff."','".$tolSuppleCommission."');\n";
	switch($Rows -> Bet_Type){
		case 1:
		case 4:
		case 21:
		case 22:
		case 23:
		case 24:
		case 25:
		case 26:
		case 28: //特碼46
			$sumStake += $tolStake;
			$sumPayOff += $tolPayOff;
			$sumCommission += $tolCommission;
			$sumSuppleStake += $tolSuppleStake;
			$sumSupplePayOff += $tolSupplePayOff;
			$sumSuppleCommission += $tolSuppleCommission;
			break;

		case 3:
		case 6:
			$sumOUStake += $tolStake;
			$sumOUPayOff += $tolPayOff;
			$sumOUCommission += $tolCommission;
			$sumSuppleOUStake += $tolSuppleStake;
			$sumSuppleOUPayOff += $tolSupplePayOff;
			$sumSuppleOUCommission += $tolSuppleCommission;
			break;

		case 16:
			$sumSOEStake += $tolStake;
			$sumSOEPayOff += $tolPayOff;
			$sumSOECommission += $tolCommission;
			$sumSuppleSOEStake += $tolSuppleStake;
			$sumSuppleSOEPayOff += $tolSupplePayOff;
			$sumSuppleSOECommission += $tolSuppleCommission;
			break;

		case 2:
		case 5:
			$sumOEStake += $tolStake;
			$sumOEPayOff += $tolPayOff;
			$sumOECommission += $tolCommission;
			$sumSuppleOEStake += $tolSuppleStake;
			$sumSuppleOEPayOff += $tolSupplePayOff;
			$sumSuppleOECommission += $tolSuppleCommission;
			break;

		case 12:
			$intNum = floor($Rows -> Number / 10);
			$arrOE16Stake[$intNum] += $tolStake;
			$arrOE16PayOff[$intNum] += $tolPayOff;
			$arrOE16Commission[$intNum] += $tolCommission;
			$arrSuppleOE16Stake[$intNum] += $tolSuppleStake;
			$arrSuppleOE16PayOff[$intNum] += $tolSupplePayOff;
			$arrSuppleOE16Commission[$intNum] += $tolSuppleCommission;
			break;

		case 13:
			$intNum = floor($Rows -> Number / 10);
			$arrOU16Stake[$intNum] += $tolStake;
			$arrOU16PayOff[$intNum] += $tolPayOff;
			$arrOU16Commission[$intNum] += $tolCommission;
			$arrSuppleOU16Stake[$intNum] += $tolSuppleStake;
			$arrSuppleOU16PayOff[$intNum] += $tolSupplePayOff;
			$arrSuppleOU16Commission[$intNum] += $tolSuppleCommission;
			break;

		case 14:
			$intNum = floor($Rows -> Number / 10);
			$arrColor16Stake[$intNum] += $tolStake;
			$arrColor16PayOff[$intNum] += $tolPayOff;
			$arrColor16Commission[$intNum] += $tolCommission;
			$arrSuppleColor16Stake[$intNum] += $tolSuppleStake;
			$arrSuppleColor16PayOff[$intNum] += $tolSupplePayOff;
			$arrSuppleColor16Commission[$intNum] += $tolSuppleCommission;
			break;

		case 27:
			$intNum = floor($Rows -> Number / 10);
			$arrSOE16Stake[$intNum] += $tolStake;
			$arrSOE16PayOff[$intNum] += $tolPayOff;
			$arrSOE16Commission[$intNum] += $tolCommission;
			$arrSuppleSOE16Stake[$intNum] += $tolSuppleStake;
			$arrSuppleSOE16PayOff[$intNum] += $tolSupplePayOff;
			$arrSuppleSOE16Commission[$intNum] += $tolSuppleCommission;
			break;

		case 17:
		case 20:
			$sumColorStake += $tolStake;
			$sumColorPayOff += $tolPayOff;
			$sumColorCommission += $tolCommission;
			$sumSuppleColorStake += $tolSuppleStake;
			$sumSuppleColorPayOff += $tolSupplePayOff;
			$sumSuppleColorCommission += $tolSuppleCommission;
			break;

		case 18:
		case 19:
			$sumAnimalsStake += $tolStake;
			$sumAnimalsPayOff += $tolPayOff;
			$sumAnimalsCommission += $tolCommission;
			$sumSuppleAnimalsStake += $tolSuppleStake;
			$sumSuppleAnimalsPayOff += $tolSupplePayOff;
			$sumSuppleAnimalsCommission += $tolSuppleCommission;
			break;

		case 29:
			$intN = floor(($Rows -> Number % 4) / 2);
			$arrHelfColorStake[$intN] += $tolStake;
			$arrHelfColorPayOff[$intN] += $tolPayOff;
			$arrHelfColorCommission[$intN] += $tolCommission;
			$arrSuppleHelfColorStake[$intN] += $tolSuppleStake;
			$arrSuppleHelfColorPayOff[$intN] += $tolSupplePayOff;
			$arrSuppleHelfColorCommission[$intN] += $tolSuppleCommission;
			break;

		case 30:
			$intN = $Rows -> Number;
			$arrSixAnimalsStake[$intN] += $tolStake;
			$arrSixAnimalsPayOff[$intN] += $tolPayOff;
			$arrSixAnimalsCommission[$intN] += $tolCommission;
			$arrSuppleSixAnimalsStake[$intN] += $tolSuppleStake;
			$arrSuppleSixAnimalsPayOff[$intN] += $tolSupplePayOff;
			$arrSuppleSixAnimalsCommission[$intN] += $tolSuppleCommission;
			break;

		default:
			$arrSumStake[$Rows -> Bet_Type] += $tolStake;
			$arrSumPayOff[$Rows -> Bet_Type] += $tolPayOff;
			$arrSumCommission[$Rows -> Bet_Type] += $tolCommission;
			$arrSumSuppleStake[$Rows -> Bet_Type] += $tolSuppleStake;
			$arrSumSupplePayOff[$Rows -> Bet_Type] += $tolSupplePayOff;
			$arrSumSuppleCommission[$Rows -> Bet_Type] += $tolSuppleCommission;
			break;
	}
}
/*=================================================================*/
header("Cache-Control: no-store, no-cache, must-revalidate");	  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");															  // HTTP/1.0
?><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
<!--
<?php 
print $strCon."\n";

foreach($arrSumStake as $intBT => $val){
	print "parent.arrSumStake[".$intBT."] = ".round($arrSumStake[$intBT]).";\n";
	print "parent.arrSumPayOff[".$intBT."] = ".round($arrSumPayOff[$intBT]).";\n";
	print "parent.arrSumCommission[".$intBT."] = ".round($arrSumCommission[$intBT]).";\n";
	print "parent.arrSumSuppleStake[".$intBT."] = ".round($arrSumSuppleStake[$intBT]).";\n";
	print "parent.arrSumSupplePayOff[".$intBT."] = ".round($arrSumSupplePayOff[$intBT]).";\n";
	print "parent.arrSumSuppleCommission[".$intBT."] = ".round($arrSumSuppleCommission[$intBT]).";\n";
	//print "parent.sumWStake[".$intBT."] = ".round($arrSumWStake[$intBT]).";\n";
}


switch($strPreBT){
	case "1":
	case "2":
	case "3":
	case "4":
	case "5":
	case "6":
	case "16":
	case "1,2,3,16":
	case "4,5,6":
		if(preg_match("/1|4/", $strPreBT)){
			print "parent.sumStake = ".round($sumStake).";\n";
			print "parent.sumPayOff = ".round($sumPayOff).";\n";
			print "parent.sumCommission = ".round($sumCommission).";\n";
			print "parent.sumSuppleStake = ".round($sumSuppleStake).";\n";
			print "parent.sumSupplePayOff = ".round($sumSupplePayOff).";\n";
			print "parent.sumSuppleCommission = ".round($sumSuppleCommission).";\n";
		}
		if(preg_match("/3|6/", $strPreBT)){
			print "parent.sumOUStake = ".round($sumOUStake).";\n";
			print "parent.sumOUPayOff = ".round($sumOUPayOff).";\n";
			print "parent.sumOUCommission = ".round($sumOUCommission).";\n";
			print "parent.sumSuppleOUStake = ".round($sumSuppleOUStake).";\n";
			print "parent.sumSuppleOUPayOff = ".round($sumSuppleOUPayOff).";\n";
			print "parent.sumSuppleOUCommission = ".round($sumSuppleOUCommission).";\n";
		}
		if(preg_match("/2|5/", $strPreBT)){
			print "parent.sumOEStake = ".round($sumOEStake).";\n";
			print "parent.sumOEPayOff = ".round($sumOEPayOff).";\n";
			print "parent.sumOECommission = ".round($sumOECommission).";\n";
			print "parent.sumSuppleOEStake = ".round($sumSuppleOEStake).";\n";
			print "parent.sumSuppleOEPayOff = ".round($sumSuppleOEPayOff).";\n";
			print "parent.sumSuppleOECommission = ".round($sumSuppleOECommission).";\n";
		}
		if(preg_match("/16/", $strPreBT)){
			print "parent.sumSOEStake = ".round($sumSOEStake).";\n";
			print "parent.sumSOEPayOff = ".round($sumSOEPayOff).";\n";
			print "parent.sumSOECommission = ".round($sumSOECommission).";\n";
			print "parent.sumSuppleSOEStake = ".round($sumSuppleSOEStake).";\n";
			print "parent.sumSuppleSOEPayOff = ".round($sumSuppleSOEPayOff).";\n";
			print "parent.sumSuppleSOECommission = ".round($sumSuppleSOECommission).";\n";
		}
		print "parent.ShowNumberOdds(".$isSpecial.");\n";
		break;

	case "7":
	case "8":
	case "9":
	case "10":
	case "11":
	case "7,8,9,10,11":
		$arrSort = getJNSortData($intGID, 10, 1, 0, "all");
		foreach($arrSort as $intBT => $arrData){
			print "parent.arrJNSort[$intBT] = new Array('".join("', '", $arrData)."');\n";
		}
		print "parent.ShowJoinNumberOdds();\n";
		break;

	case "12":
	case "13":
	case "14":
	case "27":
	case "12,13,14,27":
		if(preg_match("/12/", $strPreBT)){
			print "parent.arrOE16Stake = new Array(".join(",", $arrOE16Stake).");\n";
			print "parent.arrOE16PayOff = new Array(".join(",", $arrOE16PayOff).");\n";
			print "parent.arrOE16Commission = new Array(".join(",", $arrOE16Commission).");\n";
			print "parent.arrSuppleOE16Stake = new Array(".join(",", $arrSuppleOE16Stake).");\n";
			print "parent.arrSuppleOE16PayOff = new Array(".join(",", $arrSuppleOE16PayOff).");\n";
			print "parent.arrSuppleOE16Commission = new Array(".join(",", $arrSuppleOE16Commission).");\n";
		}
		if(preg_match("/13/", $strPreBT)){
			print "parent.arrOU16Stake = new Array(".join(",", $arrOU16Stake).");\n";
			print "parent.arrOU16PayOff = new Array(".join(",", $arrOU16PayOff).");\n";
			print "parent.arrOU16Commission = new Array(".join(",", $arrOU16Commission).");\n";
			print "parent.arrSuppleOU16Stake = new Array(".join(",", $arrSuppleOU16Stake).");\n";
			print "parent.arrSuppleOU16PayOff = new Array(".join(",", $arrSuppleOU16PayOff).");\n";
			print "parent.arrSuppleOU16Commission = new Array(".join(",", $arrSuppleOU16Commission).");\n";
		}
		if(preg_match("/14/", $strPreBT)){
			print "parent.arrColor16Stake = new Array(".join(",", $arrColor16Stake).");\n";
			print "parent.arrColor16PayOff = new Array(".join(",", $arrColor16PayOff).");\n";
			print "parent.arrColor16Commission = new Array(".join(",", $arrColor16Commission).");\n";
			print "parent.arrSuppleColor16Stake = new Array(".join(",", $arrSuppleColor16Stake).");\n";
			print "parent.arrSuppleColor16PayOff = new Array(".join(",", $arrSuppleColor16PayOff).");\n";
			print "parent.arrSuppleColor16Commission = new Array(".join(",", $arrSuppleColor16Commission).");\n";
		}
		if(preg_match("/27/", $strPreBT)){
			print "parent.arrSOE16Stake = new Array(".join(",", $arrSOE16Stake).");\n";
			print "parent.arrSOE16PayOff = new Array(".join(",", $arrSOE16PayOff).");\n";
			print "parent.arrSOE16Commission = new Array(".join(",", $arrSOE16Commission).");\n";
			print "parent.arrSuppleSOE16Stake = new Array(".join(",", $arrSuppleSOE16Stake).");\n";
			print "parent.arrSuppleSOE16PayOff = new Array(".join(",", $arrSuppleSOE16PayOff).");\n";
			print "parent.arrSuppleSOE16Commission = new Array(".join(",", $arrSuppleSOE16Commission).");\n";
		}
		print "parent.ShowNormalNumber1_6Odds(0);\n";
		break;

	case "15":
		print "parent.ShowNormalNumber1_6Odds(1);\n";
		break;

	case "17":
	case "18":
	case "17,18":
		if(preg_match("/17/", $strPreBT)){
			print "parent.sumColorStake = ".round($sumColorStake).";\n";
			print "parent.sumColorPayOff = ".round($sumColorPayOff).";\n";
			print "parent.sumColorCommission = ".round($sumColorCommission).";\n";
			print "parent.sumSuppleColorStake = ".round($sumSuppleColorStake).";\n";
			print "parent.sumSuppleColorPayOff = ".round($sumSuppleColorPayOff).";\n";
			print "parent.sumSuppleColorCommission = ".round($sumSuppleColorCommission).";\n";
		}
		if(preg_match("/18/", $strPreBT)){
			print "parent.sumAnimalsStake = ".round($sumAnimalsStake).";\n";
			print "parent.sumAnimalsPayOff = ".round($sumAnimalsPayOff).";\n";
			print "parent.sumAnimalsCommission = ".round($sumAnimalsCommission).";\n";
			print "parent.sumSuppleAnimalsStake = ".round($sumSuppleAnimalsStake).";\n";
			print "parent.sumSuppleAnimalsPayOff = ".round($sumSuppleAnimalsPayOff).";\n";
			print "parent.sumSuppleAnimalsCommission = ".round($sumSuppleAnimalsCommission).";\n";
		}
		print "parent.ShowAnimalsColorOdds();\n";
		break;

	case "19":
	case "20":
	case "19,20":
		if(preg_match("/20/", $strPreBT)){
			print "parent.sumColorStake = ".round($sumColorStake).";\n";
			print "parent.sumColorPayOff = ".round($sumColorPayOff).";\n";
			print "parent.sumColorCommission = ".round($sumColorCommission).";\n";
			print "parent.sumSuppleColorStake = ".round($sumSuppleColorStake).";\n";
			print "parent.sumSuppleColorPayOff = ".round($sumSuppleColorPayOff).";\n";
			print "parent.sumSuppleColorCommission = ".round($sumSuppleColorCommission).";\n";
		}
		if(preg_match("/19/", $strPreBT)){
			print "parent.sumAnimalsStake = ".round($sumAnimalsStake).";\n";
			print "parent.sumAnimalsPayOff = ".round($sumAnimalsPayOff).";\n";
			print "parent.sumAnimalsCommission = ".round($sumAnimalsCommission).";\n";
			print "parent.sumSuppleAnimalsStake = ".round($sumSuppleAnimalsStake).";\n";
			print "parent.sumSuppleAnimalsPayOff = ".round($sumSuppleAnimalsPayOff).";\n";
			print "parent.sumSuppleAnimalsCommission = ".round($sumSuppleAnimalsCommission).";\n";
		}
		print "parent.ShowAnimalsMantissaOdds();\n";
		break;

	case "21":
	case "22":
	case "23":
	case "24":
	case "25":
	case "26":
		print "parent.sumStake = ".round($sumStake).";\n";
		print "parent.sumPayOff = ".round($sumPayOff).";\n";
		print "parent.sumCommission = ".round($sumCommission).";\n";
		print "parent.sumSuppleStake = ".round($sumSuppleStake).";\n";
		print "parent.sumSupplePayOff = ".round($sumSupplePayOff).";\n";
		print "parent.sumSuppleCommission = ".round($sumSuppleCommission).";\n";
		print "parent.ShowNumberOdds(".$isSpecial.");\n";
		break;

	case "29":
		print "parent.arrHelfColorStake = new Array(".join(",", $arrHelfColorStake).");\n";
		print "parent.arrHelfColorPayOff = new Array(".join(",", $arrHelfColorPayOff).");\n";
		print "parent.arrHelfColorCommission = new Array(".join(",", $arrHelfColorCommission).");\n";
		print "parent.arrSuppleHelfColorStake = new Array(".join(",", $arrSuppleHelfColorStake).");\n";
		print "parent.arrSuppleHelfColorPayOff = new Array(".join(",", $arrSuppleHelfColorPayOff).");\n";
		print "parent.arrSuppleHelfColorCommission = new Array(".join(",", $arrSuppleHelfColorCommission).");\n";
		print "parent.ShowHelfColorOdds();\n";
		break;

	case "30":
		print "parent.arrSixAnimalsStake = new Array(".join(",", $arrSixAnimalsStake).");\n";
		print "parent.arrSixAnimalsPayOff = new Array(".join(",", $arrSixAnimalsPayOff).");\n";
		print "parent.arrSixAnimalsCommission = new Array(".join(",", $arrSixAnimalsCommission).");\n";
		print "parent.arrSuppleSixAnimalsStake = new Array(".join(",", $arrSuppleSixAnimalsStake).");\n";
		print "parent.arrSuppleSixAnimalsPayOff = new Array(".join(",", $arrSuppleSixAnimalsPayOff).");\n";
		print "parent.arrSuppleSixAnimalsCommission = new Array(".join(",", $arrSuppleSixAnimalsCommission).");\n";
		print "parent.ShowSixAnimalsOdds();\n";
		break;

	case "31":
		print "parent.ShowFiveNotWinNumber();\n";
		break;

	case "32":
	case "33":
	case "34":
	case "35":
	case "36":
	case "37":
	case "32,33,34,35,36,37":
		print "parent.ShowBT3243Number(32);\n";
		break;

	case "38":
	case "39":
	case "40":
	case "41":
	case "42":
	case "43":
	case "38,39,40,41,42,43":
		print "parent.ShowBT3243Number(38);\n";
		break;
}

if($_data["isGetSuppleOdds"] == "Y" && $arrResult["WagerCon"] != ""){
	$arrResult["WagerCon"] = str_replace(chr(10), "", $arrResult["WagerTip"]."<br />".$arrResult["WagerCon"]);
	$arrResult["WagerCon"] = str_replace(chr(13), "", $arrResult["WagerCon"]);
	print "parent.SuppleResult.innerHTML='".addslashes($arrResult["WagerCon"])."';\n";
	print "parent.open_SuppleResultWin();\n";
}
?>
//-->
</script>